package cn.new7as.cas5s.ui.record;


import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;

import androidx.annotation.NonNull;

import com.hjq.http.EasyHttp;
import com.hjq.http.listener.OnHttpListener;

import java.util.List;

import cn.new7as.cas5s.tool.util.Utils;
import cn.new7as.cas5s.ui.slideshow.BaseActivity;
import cn.new7as.cas5s.databinding.ActivityOrdersBinding;
import cn.new7as.cas5s.ui.easy.netapi.HttpData;
import cn.new7as.cas5s.ui.easy.netapi.RecordsApi;


public class RecordsActivity extends BaseActivity {


    private ActivityOrdersBinding binding;

    @SuppressLint("MissingPermission")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityOrdersBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        setop("Records");
        initV();
        //

    }

    @Override
    public void initV() {
        super.initV();
        show();
        getRecord();
    }

    private void getRecord() {
        EasyHttp.get(this)
                .api(new RecordsApi(getunique(), 19)).request(new OnHttpListener<HttpData<List<RecordsApi.Data>>>() {

                    @Override
                    public void onHttpSuccess(@NonNull HttpData<List<RecordsApi.Data>> result) {

                        hide();
                        binding.ordersgride.setAdapter(new Recordsadapter(result.getResult(), RecordsActivity.this));
                        binding.ordersgride.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                Utils.goextra(RecordsActivity.this, RecordsDetailActivity.class, "" + result.getResult().get(position).id);

                            }
                        });

                    }

                    @Override
                    public void onHttpFail(@NonNull Throwable throwable) {
                        deal(throwable);
                    }
                });
    }


}